<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| This file is where you may define all of the routes that are handled
| by your application. Just tell Laravel the URIs it should respond
| to using a Closure or controller method. Build something great!
|
*/


Auth::routes();

//前台
Route::group(['namespace' => 'Home'], function ($router) {
    //首页
    $router->get('/', 'IndexController@index');
    $router->get('/a_{id}.html', 'IndexController@show');
});

Route::group(['namespace' => 'Home', 'middleware' => 'auth'], function ($router) {
    //发布留言
    $router->resource('/message', 'MessageController');
});


//后台
Route::group(['prefix' => 'admin', 'namespace' => 'Admin'], function ($router) {
    //登录
    $router->get('login', 'LoginController@showLoginForm')->name('admin.login');
    $router->post('login', 'LoginController@login');
    $router->post('logout', 'LoginController@logout');
});

Route::group(['prefix' => 'admin', 'namespace' => 'Admin', 'middleware' => 'auth.admin:admin'], function ($router) {
    //首页
    $router->get('/', 'IndexController@index');
    //留言
    $router->resource('message', 'MessageController');
    //用户
    $router->resource('user', 'UserController');
});